#include "PreCompile.hpp"
#include "InputFileSetTests.hpp"
#include "TestProjectLoading.hpp"
#include "TestWrongProjectFiles.hpp"
#include "SettingsTests.hpp"

int main()
{
  try
  {
    BuildNG::init_shared();
    BuildNG::init_libbuildng("../../Win32Settings.xml");

    BuildNG::SettingsTests settings_tests;
    settings_tests.test_get_setting_string_from_elem_content();
    settings_tests.test_get_setting_string_from_attribute();

    BuildNG::InputFileSetTests input_file_tests;
    input_file_tests.test_simple_file_set();
    input_file_tests.test_nested_groups();
    input_file_tests.test_empty_group();
    input_file_tests.test_skip_empty_groups();

    BuildNG::TestProjectLoading::simple_loading_test();
    BuildNG::TestProjectLoading::test_project_root_dir();
    BuildNG::TestProjectLoading::test_name_collision();

    BuildNG::TestWrongProjectFiles::test_invalid_xml();
    
    BuildNG::shutdown_libbuildng();
    BuildNG::shutdown_shared();
    
    return 0;
  }
  catch(const std::exception &err)
  {
    std::cout << "The following exception was thrown: " << std::string(err.what()) << std::endl;
    assert(!"unhandled exception");
  }
  catch(const Glib::Exception &err)
  {
    std::cout << "The following exception was thrown: " << err.what() << std::endl;
    assert(!"unhandled exception");
  }
  catch(...)
  {
    assert(!"unhandled exception of a type different from std::exception");
  }
}
